<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column
        property="createTime"
        :formatter="formatterTime"
        label="检测时间"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="阻抗"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.impedance }}
        </template>
      </el-table-column>
      <el-table-column
        label="温度"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.temperature }}
        </template>
      </el-table-column>
      <el-table-column
        label="铵离子"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.ammonia }}
        </template>
      </el-table-column>
      <el-table-column
        label="氮离子"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.nitrogen }}
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getDetail } from "@/api/table";
import dtime from "time-formater";

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "gray",
        deleted: "danger"
      };
      return statusMap[status];
    }
  },
  data() {
    return {
      list: null,
      listLoading: true,
      listQuery: {}
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      this.listLoading = true;
      this.listQuery.deviceInfoId = this.$route.query.deviceInfoId;
      getDetail(this.listQuery).then(response => {
        this.list = response.data;
        this.listLoading = false;
      });
    },
    formatterTime(data) {
      return dtime(data.createTime).format("YYYY-MM-DD HH:mm:ss");
    }
  }
};
</script>
